DecoderControl, InputStream: use Mutex/Cond instead of GMutex/GCond

This commit is contained in:
Max Kellermann
2013-01-27 17:20:50 +01:00
parent 257a0dee75
commit 6f3d70b5e2
46 changed files with 182 additions and 234 deletions

View File

@@ -186,8 +186,8 @@ int main(int argc, char **argv)
/* open the playlist */
GMutex *mutex = g_mutex_new();
GCond *cond = g_cond_new();
Mutex mutex;
Cond cond;
playlist = playlist_list_open_uri(uri, mutex, cond);
if (playlist == NULL) {
@@ -243,9 +243,6 @@ int main(int argc, char **argv)
if (is != NULL)
input_stream_close(is);
g_cond_free(cond);
g_mutex_free(mutex);
decoder_plugin_deinit_all();
playlist_list_global_finish();
input_stream_global_finish();

View File

@@ -135,8 +135,8 @@ int main(int argc, char **argv)
/* open the stream and dump it */
GMutex *mutex = g_mutex_new();
GCond *cond = g_cond_new();
Mutex mutex;
Cond cond;
is = input_stream_open(argv[1], mutex, cond, &error);
if (is != NULL) {
@@ -151,9 +151,6 @@ int main(int argc, char **argv)
ret = 2;
}
g_cond_free(cond);
g_mutex_free(mutex);
/* deinitialize everything */
input_stream_global_finish();

View File

@@ -186,8 +186,8 @@ int main(int argc, char **argv)
bool success = decoder_plugin_scan_file(plugin, path,
&print_handler, NULL);
if (!success && plugin->scan_stream != NULL) {
GMutex *mutex = g_mutex_new();
GCond *cond = g_cond_new();
Mutex mutex;
Cond cond;
struct input_stream *is =
input_stream_open(path, mutex, cond, &error);
@@ -199,15 +199,15 @@ int main(int argc, char **argv)
return 1;
}
g_mutex_lock(mutex);
mutex.lock();
while (!is->ready) {
g_cond_wait(cond, mutex);
cond.wait(mutex);
input_stream_update(is);
}
if (!input_stream_check(is, &error)) {
g_mutex_unlock(mutex);
mutex.unlock();
g_printerr("Failed to read %s: %s\n",
path, error->message);
@@ -216,14 +216,11 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
g_mutex_unlock(mutex);
mutex.unlock();
success = decoder_plugin_scan_stream(plugin, is,
&print_handler, NULL);
input_stream_close(is);
g_cond_free(cond);
g_mutex_free(mutex);
}
decoder_plugin_deinit_all();

View File

@@ -188,8 +188,8 @@ int main(int argc, char **argv)
decoder_plugin_file_decode(decoder.plugin, &decoder,
decoder.uri);
} else if (decoder.plugin->stream_decode != NULL) {
GMutex *mutex = g_mutex_new();
GCond *cond = g_cond_new();
Mutex mutex;
Cond cond;
struct input_stream *is =
input_stream_open(decoder.uri, mutex, cond, &error);
@@ -206,9 +206,6 @@ int main(int argc, char **argv)
decoder_plugin_stream_decode(decoder.plugin, &decoder, is);
input_stream_close(is);
g_cond_free(cond);
g_mutex_free(mutex);
} else {
g_printerr("Decoder plugin is not usable\n");
return 1;

View File

@@ -149,8 +149,8 @@ int main(int argc, char **argv)
/* open the stream and dump it */
GMutex *mutex = g_mutex_new();
GCond *cond = g_cond_new();
Mutex mutex;
Cond cond;
is = input_stream_open(argv[1], mutex, cond, &error);
if (is != NULL) {
@@ -165,9 +165,6 @@ int main(int argc, char **argv)
ret = 2;
}
g_cond_free(cond);
g_mutex_free(mutex);
/* deinitialize everything */
input_stream_global_finish();