mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
Update: Made dumpfile writing more uniform
This commit is contained in:
parent
4ecee870c9
commit
dd3ce7462b
@ -368,33 +368,16 @@ static void ebml_free_client_data (client_t *client)
|
|||||||
client->format_data = NULL;
|
client->format_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ebml_write_buf_to_file_fail (source_t *source)
|
|
||||||
{
|
|
||||||
ICECAST_LOG_WARN("Write to dump file failed, disabling");
|
|
||||||
fclose (source->dumpfile);
|
|
||||||
source->dumpfile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ebml_write_buf_to_file (source_t *source, refbuf_t *refbuf)
|
static void ebml_write_buf_to_file (source_t *source, refbuf_t *refbuf)
|
||||||
{
|
{
|
||||||
|
|
||||||
ebml_source_state_t *ebml_source_state = source->format->_state;
|
ebml_source_state_t *ebml_source_state = source->format->_state;
|
||||||
|
|
||||||
if ( ! ebml_source_state->file_headers_written)
|
if (!ebml_source_state->file_headers_written) {
|
||||||
{
|
if (source_write_dumpfile(source, ebml_source_state->header->data, ebml_source_state->header->len))
|
||||||
if (fwrite (ebml_source_state->header->data, 1,
|
|
||||||
ebml_source_state->header->len,
|
|
||||||
source->dumpfile) != ebml_source_state->header->len)
|
|
||||||
ebml_write_buf_to_file_fail(source);
|
|
||||||
else
|
|
||||||
ebml_source_state->file_headers_written = true;
|
ebml_source_state->file_headers_written = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) != refbuf->len)
|
source_write_dumpfile(source, refbuf->data, refbuf->len);
|
||||||
{
|
|
||||||
ebml_write_buf_to_file_fail(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* internal ebml parsing */
|
/* internal ebml parsing */
|
||||||
|
@ -760,13 +760,6 @@ static void free_mp3_client_data (client_t *client)
|
|||||||
|
|
||||||
static void write_mp3_to_file (source_t *source, refbuf_t *refbuf)
|
static void write_mp3_to_file (source_t *source, refbuf_t *refbuf)
|
||||||
{
|
{
|
||||||
if (refbuf->len == 0)
|
source_write_dumpfile(source, refbuf->data, refbuf->len);
|
||||||
return;
|
|
||||||
if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) < (size_t)refbuf->len)
|
|
||||||
{
|
|
||||||
ICECAST_LOG_WARN("Write to dump file failed, disabling");
|
|
||||||
fclose (source->dumpfile);
|
|
||||||
source->dumpfile = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,21 +565,6 @@ static int write_buf_to_client(client_t *client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int write_ogg_data (source_t *source, refbuf_t *refbuf)
|
|
||||||
{
|
|
||||||
int ret = 1;
|
|
||||||
|
|
||||||
if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) != refbuf->len)
|
|
||||||
{
|
|
||||||
ICECAST_LOG_WARN("Write to dump file failed, disabling");
|
|
||||||
fclose (source->dumpfile);
|
|
||||||
source->dumpfile = NULL;
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void write_ogg_to_file (source_t *source, refbuf_t *refbuf)
|
static void write_ogg_to_file (source_t *source, refbuf_t *refbuf)
|
||||||
{
|
{
|
||||||
ogg_state_t *ogg_info = source->format->_state;
|
ogg_state_t *ogg_info = source->format->_state;
|
||||||
@ -589,13 +574,11 @@ static void write_ogg_to_file (source_t *source, refbuf_t *refbuf)
|
|||||||
refbuf_t *header = refbuf->associated;
|
refbuf_t *header = refbuf->associated;
|
||||||
while (header)
|
while (header)
|
||||||
{
|
{
|
||||||
if (write_ogg_data (source, header) == 0)
|
if (!source_write_dumpfile(source, header->data, header->len))
|
||||||
return;
|
return;
|
||||||
header = header->next;
|
header = header->next;
|
||||||
}
|
}
|
||||||
ogg_info->file_headers = refbuf->associated;
|
ogg_info->file_headers = refbuf->associated;
|
||||||
}
|
}
|
||||||
write_ogg_data (source, refbuf);
|
source_write_dumpfile(source, refbuf->data, refbuf->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
19
src/source.c
19
src/source.c
@ -1461,3 +1461,22 @@ void source_recheck_mounts (int update_all)
|
|||||||
avl_tree_unlock (global.source_tree);
|
avl_tree_unlock (global.source_tree);
|
||||||
config_release_config();
|
config_release_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Writes a buffer of raw data to a dumpfile. returns true if the write was successful (and complete). */
|
||||||
|
bool source_write_dumpfile(source_t *source, const void *buffer, size_t len)
|
||||||
|
{
|
||||||
|
if (!source->dumpfile)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (fwrite(buffer, 1, len, source->dumpfile) != len) {
|
||||||
|
ICECAST_LOG_WARN("Write to dump file failed, disabling");
|
||||||
|
fclose(source->dumpfile);
|
||||||
|
source->dumpfile = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -104,6 +104,9 @@ int source_remove_client(void *key);
|
|||||||
void source_main(source_t *source);
|
void source_main(source_t *source);
|
||||||
void source_recheck_mounts (int update_all);
|
void source_recheck_mounts (int update_all);
|
||||||
|
|
||||||
|
/* Writes a buffer of raw data to a dumpfile. returns true if the write was successful (and complete). */
|
||||||
|
bool source_write_dumpfile(source_t *source, const void *buffer, size_t len);
|
||||||
|
|
||||||
extern mutex_t move_clients_mutex;
|
extern mutex_t move_clients_mutex;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user