mediainfo-native 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a782db0907a8b6d42f2bcbfd5139d5cbc90abba9
4
- data.tar.gz: 5b1db6d9c65e0df426e7c6d25698304777c5cbc1
3
+ metadata.gz: e0b1502f91c83eca2c8f057f9df9f5048afcafe0
4
+ data.tar.gz: a181df52fa311bb36dcd6aa8e7669328a098d2ea
5
5
  SHA512:
6
- metadata.gz: 7daf29e66426fdaa52f534302b218f0730091555af5c7de80353122ede3fb1d4e563c3f4b0744922e235f6601ae7bf55d0104e2e8b12205ed7fed438e06f710f
7
- data.tar.gz: 1f40980b01405e5d98b640cd9e31d81db582cff8ab7eca70d7d8d0e64f06b64c5fa6042bfaf0d9192ea30f37cf68324fc9a8466f2704e69ec5b8a601902b4f4e
6
+ metadata.gz: e3f5f0c3fe7bdba919b0621e64018b09f28fd14c55689559382e5a6abdd042f457986879d29d3ba59573aac3334021f5ab47bd4824578f64fde2784b78b391bd
7
+ data.tar.gz: ffe53edefd1ae6e968b61c19602ef93e4ac8f633c93c2f52721ea712648a36ba5ddb05b46d6949132e1e672895dce21d1e763c389555c7cb2348f141c6379ad4
@@ -1,3 +1,6 @@
1
+ #include <ruby.h>
2
+ #include <ruby/thread.h>
3
+
1
4
  #include "MediaInfoDLL.h"
2
5
  #include "mediainfo_wrapper.h"
3
6
  #include "unicode.h"
@@ -11,6 +14,12 @@ namespace MediaInfoNative
11
14
  MediaInfoWrapper* var; \
12
15
  Data_Get_Struct(self, MediaInfoWrapper, var)
13
16
 
17
+ typedef struct {
18
+ MediaInfoWrapper* miw;
19
+ MediaInfoDLL::String path;
20
+ int result;
21
+ } OpenParams;
22
+
14
23
  extern "C"
15
24
  {
16
25
 
@@ -35,12 +44,26 @@ extern "C"
35
44
  return Qnil;
36
45
  }
37
46
 
47
+ static void* miw_open_without_gvl(void* ptr) {
48
+ OpenParams* params = (OpenParams*) ptr;
49
+ params->result = params->miw->open(params->path);
50
+ return NULL;
51
+ }
52
+
38
53
  static VALUE miw_open(VALUE self, VALUE path)
39
54
  {
40
55
  Check_Type(path, T_STRING);
41
56
  GET_WRAPPER(miw);
42
57
 
43
- miw->open(path);
58
+ OpenParams params = { miw, value_to_ansi_string(path), 0 };
59
+ rb_thread_call_without_gvl(miw_open_without_gvl, (void*) &params, NULL, NULL);
60
+
61
+ switch(params.result) {
62
+ case 1:
63
+ rb_raise(rb_eStandardError, "already opened a file");
64
+ case 2:
65
+ rb_raise(rb_eStandardError, "failed to open");
66
+ }
44
67
 
45
68
  if(rb_block_given_p())
46
69
  return rb_ensure((RUBYFUNC) rb_yield, Qnil, (RUBYFUNC) miw_close, self);
@@ -60,7 +83,7 @@ extern "C"
60
83
  Check_Type(path, T_STRING);
61
84
  GET_WRAPPER(miw);
62
85
 
63
- miw->open(path);
86
+ miw->open(value_to_ansi_string(path));
64
87
  VALUE inform = miw->inform();
65
88
  miw->close();
66
89
 
@@ -138,17 +161,16 @@ MediaInfoWrapper::~MediaInfoWrapper()
138
161
  delete mi;
139
162
  }
140
163
 
141
- void MediaInfoWrapper::open(VALUE path)
164
+ int MediaInfoWrapper::open(std::string path)
142
165
  {
143
166
  if(file_opened)
144
- rb_raise(rb_eStandardError, "already opened a file");
145
-
146
- MediaInfoDLL::String mi_path = value_to_ansi_string(path);
167
+ return 1;
147
168
 
148
- if(mi->Open(mi_path) != 1)
149
- rb_raise(rb_eStandardError, "failed to open");
169
+ if(mi->Open(path) != 1)
170
+ return 2;
150
171
 
151
172
  file_opened = true;
173
+ return 0;
152
174
  }
153
175
 
154
176
  void MediaInfoWrapper::close()
@@ -3,9 +3,10 @@
3
3
 
4
4
  #include <list>
5
5
  #include <ruby.h>
6
+ #include <string>
7
+ #include "MediaInfoDLL.h"
6
8
  #include "basestream.h"
7
9
 
8
- namespace MediaInfoDLL { class MediaInfo; }
9
10
 
10
11
  namespace MediaInfoNative
11
12
  {
@@ -16,7 +17,7 @@ public:
16
17
  MediaInfoWrapper();
17
18
  ~MediaInfoWrapper();
18
19
 
19
- void open(VALUE path);
20
+ int open(MediaInfoDLL::String path);
20
21
  void close();
21
22
  VALUE wrapStreams();
22
23
 
@@ -1,3 +1,3 @@
1
1
  module MediaInfoNative
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediainfo-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlavourSys Technology GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler